all_video_file = '/home/sean/data/ILSVRC/ImageSets/VID/train_video_remove_no_object.txt'
one_class_video_path = '/home/sean/data/ILSVRC/ImageSets/VID/train_'
write_path = '/home/sean/data/ILSVRC/ImageSets/VID/train_video_'

VID_CLASSES_name =(  # always index 0
    'airplane', #1 airplane
    'antelope', #2 antelope
    'bear', #3 bear
    'bicycle', #4 bicycle
    'bird', #5 bird
    'bus', #6 bus
    'car', #7 car
    'cattle', #8 cattle
    'dog', #9 dog
    'domestic_cat', #10 domestic_cat
    'elephant', #11 elephant
    'fox', #12 fox
    'giant_panda', #13 giant_panda
    'hamster', #14 hamster
    'horse', #15 horse
    'lion', #16 lion
    'lizard', #17 lizard
    'monkey', #18 monkey
    'motorcycle', #19 motorcycle
    'rabbit', #20 rabbit
    'red_panda', #21 red_panda
    'sheep', #22 sheep
    'snake', #23 snake
    'squirrel', #24 squirrel
    'tiger', #25 tiger
    'train', #26 train
    'turtle', #27 turtle
    'watercraft', #28 watercraft
    'whale', #29 whale
    'zebra', #30 zebra
)

train_class = 'bicycle'
write_file = write_path + str(VID_CLASSES_name.index(train_class)+1)+'.txt'
one_class_video_file = one_class_video_path + str(VID_CLASSES_name.index(train_class)+1)+'.txt'

af = open(all_video_file, 'r')
al = af.readlines()
all_video_list = []
for line in al:
    all_video_list.append(line.split(' ')[0])
with open(write_file, 'w') as wf:
    for line in open(one_class_video_file, 'r'):
        video = line.split(' ')[0]
        video_write = al[all_video_list.index(video)]
        wf.write(video_write)